package com.topscomm.meet.job;

import com.topscomm.meet.pojo.MeetTaskDetailEntity;
import com.topscomm.meet.service.IMeetTaskDetailService;
import com.topscomm.pub.util.StringBufferProxy;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author: shenyouyi
 * @date: 2020-08-28
 * @description: 创建OA会议任务Job
 * @modify:
 */
@JobHandler("meetTaskCreateToOAJob")
@Component
public class MeetTaskCreateToOAJob extends IJobHandler {

    @Autowired
    private IMeetTaskDetailService meetTaskDetailService;

    @Override
    public ReturnT<String> execute(String s) throws Exception {
        StringBufferProxy sql = new StringBufferProxy();
        int maxPushTimes = 3;
        sql.appendSingle(MeetTaskDetailEntity.FieldFailedtimes + " < {0}", maxPushTimes);
        List<MeetTaskDetailEntity> meetTaskDetailEntityList = meetTaskDetailService.queryByWhere(sql.toString());
        meetTaskDetailService.createOATask(meetTaskDetailEntityList);
        return ReturnT.SUCCESS;
    }

}
